
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<%@ include file="/include/head.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/servicePro/jquery.uploadify.min.js"></script>
<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/servicePro/uploadify.css">
<script type="text/javascript">
      $(function(){  
		   /**加载修改活动框**/
		  $("#update_manager_dialog").dialog({
		    autoOpen : false,
		    width : 700,
		    draggable : true,
		    resizable : false,
		    height:550,
		    buttons : [ {
		      text : "提交",
		      click : function() {
		      	  updateManager();
		     	 $(this).dialog("close");		      	
		      }
		    }, {
		      text : "取消",
		      click : function() {
		        $(this).dialog("close");
		        
		      }
		    } ]
	  });
	   /**加载添加活动框**/
		  $("#add_manager_dialog").dialog({
		    autoOpen : false,
		    width : 700,
		    draggable : true,
		    resizable : false,
		    height:550,
		    buttons : [ {
		      text : "提交",
		      click : function() {
		      	  addManager();
		     	 $(this).dialog("close");		      	
		      }
		    }, {
		      text : "取消",
		      click : function() {
		        $(this).dialog("close");
		        
		      }
		    } ]
	  });
		  $("#add_manager").click(function(e) {
	        closeOtherJDialog();
	        e.stopPropagation();
	        $("#add_manager_dialog").dialog('open');
	     });
	     
	 /**添加活动上传图片**/
     $("#file_upload").uploadify({
        		    'buttonText' : '请选择活动图片',
        		    'height' : 30,
        	        'swf' : '<%=request.getContextPath()%>/resources/servicePro/uploadify.swf',
        	        'uploader' : '<%=request.getContextPath()%>/back/actBack/uploadlogo.do',
        	        'width' : 120,
        	        'multi'           : false,
                    "auto"            : false,
                    "dnd"             : true,
        	        "fileTypeExts"    : "*.png;*.jpg;*.bmp;*.gif",
                    "fileSizeLimit"   : "2MB",
        	        'fileObjName'   : 'file',
        	        'onUploadSuccess' : function(file, data, response) {
        	        	      data = eval("(" + data + ")");      	        
        	                 alert( file.name + ' 上传成功！ ');
                           $("#iphoto").val(data.picurl);
                            $("#iifUpPic").val("1");
        	            $("#uploadButton").hide();
        	            
        	        },
         'onFallback' : function() {
           alert('Flash was not detected.');
        },
         "onSelect" : function(file) {
          if ($("#file_upload-queue").children().length == 1) {
            $("#uploadButton").show();
            $("#onlyOneImg").hide();
          } else {
          
            $("#uploadButton").hide();
            $("#onlyOneImg").show();
          }
        },
           "onCancel" : function() {
          if ($("#file_upload-queue").children().length == 2) {
            $("#uploadButton").show();
            $("#onlyOneImg").hide();
          } else if ($("#file_upload-queue").children().length == 1) {
            $("#uploadButton").hide();
          } else {
            $("#uploadButton").hide();
            $("#onlyOneImg").show();
          }
        },
 		        });
 		        
      /**修改活动上传图片**/
     $("#ufile_upload").uploadify({
        		    'buttonText' : '请选择活动图片',
        		    'height' : 30,
        	        'swf' : '<%=request.getContextPath()%>/resources/servicePro/uploadify.swf',
        	        'uploader' : '<%=request.getContextPath()%>/back/actBack/uploadlogo.do',
        	        'width' : 120,
        	        'multi'           : false,
                    "auto"            : false,
                    "dnd"             : true,
        	        "fileTypeExts"    : "*.png;*.jpg;*.bmp;*.gif",
                    "fileSizeLimit"   : "2MB",
        	        'fileObjName'   : 'file',
        	        'onUploadSuccess' : function(file, data, response) {
        	        	      data = eval("(" + data + ")");      	        
        	                 alert( file.name + ' 上传成功！ ');
                           $("#uphoto").val(data.picurl);
                            $("#uifUpPic").val("1");
        	            $("#uuploadButton").hide();
        	            
        	        },
         'onFallback' : function() {
           alert('Flash was not detected.');
        },
         "onSelect" : function(file) {
            $("#uuploadButton").show();
        },
           "onCancel" : function() {
            $("#uuploadButton").hide();
            $("#uonlyOneImg").show();
        },
 		        });
      }); 
    
    /**修改活动信息**/
     function updateManager(){
        var uployid=$.trim($("#uployid").val()); 
	    var iployname=$.trim($("#uployname").val());  
	    var iploydesc=$.trim($("#uployDesc").val());
	    var istartTime=$.trim($("#ustartTime").val());  
	    var iendTime=$.trim($("#uendTime").val());  
	    var iphoto=$.trim($("#uphoto").val()); 
	    var uploypic=$.trim($("#uploypic").val());  
	    var iifUpPic=$.trim($("#uifUpPic").val()); 
	    if(iployname.length==0  || iploydesc.length==0||istartTime.length==0  || iendTime.length==0  || iphoto.length==0 || uploypic.length==0|| iifUpPic.length==0){
	      alert("输入信息不能为空!");
	        return false;
	    } 
	     $.ajax( {
				type : "POST",
				url : "<%=request.getContextPath()%>/back/actBack/optActivity.do",
				data:{"ploy_id":uployid,"ploy_name":iployname,"ploy_desc":iploydesc,"start_time":istartTime,"end_time":iendTime,"photo":iphoto,"ifUpPic":iifUpPic,"ploy_pic":uploypic},
				dataType: "json",
				async : false,
				success : function(data) {
					if(data.code=="0000"){
			       		 alert("操作成功!");
			       		 location.reload();
			       }else{
			           alert(data.code+data.codeMsg);
			       }
				}
		  });         
     }
      /**添加活动信息**/
     function addManager(){
	    var iployname=$.trim($("#iployname").val());  
	    var iploydesc=$.trim($("#iployDesc").val());
	    var istartTime=$.trim($("#istartTime").val());  
	    var iendTime=$.trim($("#iendTime").val());  
	    var iphoto=$.trim($("#iphoto").val());  
	    var iifUpPic=$.trim($("#iifUpPic").val()); 
	    if(iployname.length==0  || iploydesc.length==0||istartTime.length==0  || iendTime.length==0  || iphoto.length==0 || iifUpPic.length==0){
	      alert("输入信息不能为空!");
	        return false;
	    } 
	     $.ajax( {
				type : "POST",
				url : "<%=request.getContextPath()%>/back/actBack/optActivity.do",
				data:{"ploy_id":"1","ploy_name":iployname,"ploy_desc":iploydesc,"start_time":istartTime,"end_time":iendTime,"photo":iphoto,"ifUpPic":iifUpPic},
				dataType: "json",
				async : false,
				success : function(data) {
					if(data.code=="0000"){
			       		 alert("操作成功!");
			       		 location.reload();
			       }else{
			           alert(data.code+data.codeMsg);
			       }
				}
		  });            
     }
   
   </script>
<title>Document</title>


</head>
<body  >
	<div class="container">
		<div class="main_top">

			<div class="main_right fr span10">

				<div class="box pl5">
					<div class="box_border">
						<div class="box_top">
							<div class="box_top_l fl">
								<b class="pl15">数据</b>
							</div>
						</div>
						<div class="box_center">
					<form id="form1" method="post" action="<%=request.getContextPath()%>/back/actBack/getActivityBeans.do">
								<div class="searchDiv fl">
						
									<b>请输入发布人姓名或活动名称进行搜索</b>
									 <input type="text" name="findkey" class="input-text lh30" style="width:300px" maxlength="50" value="${findkey }">  
									<b>创建时间：</b>
									<input type="text" onclick="WdatePicker();" id="fromDateInput" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'toDateInput\')}', minDate:'#F{$dp.$D(\'toDateInput\',{M:-2})}'})"
										class="Wdate" style="width:150px;padding-left:3px;"
										name="startTime"
										value="${startTime}" />&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;
										<input type="text" onclick="WdatePicker();" id="fromDateInput" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'toDateInput\')}', minDate:'#F{$dp.$D(\'toDateInput\',{M:-2})}'})"
										class="Wdate" style="width:150px;padding-left:3px;"
										name="endTime"
										value="${endTime}" />
									
									 <input type="submit" value="搜索" class="btn btn82 btn_search">

								</div>
						
							</form>
					
								<div class="searchDiv fr">
								<input type="button"  id="add_manager"  class="new_btn new_btn_publish new_btn_big" 
											value="发布活动">
									    
								</div>
							</form>
							<div id="table" class=" fl mt10">
								<div class="box span10 oh">
									<table width="100%" border="0" cellpadding="0" cellspacing="0"
										class="list_table">
										<tr>
											<th width="1.5%">序号</th>
											<th width="5%">活动名称</th>
											<th width="3%">发布人</th>
											<th width="5%">缩略图</th>
											<th width="2%">状态</th>
											<th width="5%">开始时间</th>
											<th width="5%">结束时间</th>
											<th width="5%">创建时间</th>
											<th width="5%">操作</th>
										</tr>
										<c:if test="${fn:length(activityBeans)==0}"><tr class="tr"><td align="center" colspan="9">暂无数据</td> </tr></c:if>
										<c:if test="${fn:length(activityBeans)>0}">
										<c:forEach items="${activityBeans}" var="activity" varStatus="abc">
											<tr class="tr">
											    <td align="center"><c:out value="${(PageBean.currentpage-1)*PageBean.pagesize+abc.index + 1}" /></td>
												<td align="center"><c:out value="${activity.ploy_name}" /></td>
												<td align="center"><c:out value="${activity.user_name}" /></td>
												<td align="center">
                                                 <a href="<%=imgPath %>${activity.photo}" data-lightbox="image-1" id="showImg" > <IMG alt="活动缩略图" width="50" height="50" src="<%=imgPath %>${activity.photo}"/></a>
                                                 </td>
												<td align="center">
													<c:out value="${activity.state}" />
												<%--  <c:if test="${activity.is_eff == '0' }">无效</c:if>
												  <c:if test="${activity.is_eff == '1' }">有效</c:if>--%>
												</td>
												<td align="center"><c:out value="${activity.start_time}" /></td>
												<td align="center"><c:out value="${activity.end_time}" /></td>
												<td align="center"><c:out value="${activity.create_time}" /></td>
												<td align="center">
													<c:if test="${activity.state != '已结束'}">
														<input type="button"  name="update" class="new_btn new_btn_up" value="更新"  >
													</c:if>
													<c:if test="${activity.state == '已结束' && !activity.honors}">
														<input type="button" name="honors" class="new_btn new_btn_add" value="评奖" onclick="javascript:window.location='getHonors.do?id=${activity.ploy_id}'"  >
													</c:if>
													<c:if test="${activity.honors}">
														<input type="button" name="honorsEnd" class="new_btn new_btn_stop" value="已评奖"  >
													</c:if>
												  </td>
												  <td style="display:none;"><c:out value="${activity.ploy_id}" /></td>
												  <td style="display:none;"><c:out value="${activity.is_eff}" /></td>
												  <td style="display:none;"><c:out value="${activity.ploy_desc}" /></td>
												  <td style="display:none;"><c:out value="${activity.photo}" /></td>
												  <td style="display:none;"><c:out value="${activity.ploy_pic}" /></td>
											</tr>
										</c:forEach>
                                     </c:if>
									</table>
									<div class="fr fontblack mt25 mb20 mr20">
										每页条数：<a href="<%=request.getContextPath()%>/back/actBack/getActivityBeans.do?pz=5"
											class="${pageSize == 5 ? 'fontpink' : ''}">5</a> | <a
											href="<%=request.getContextPath()%>/back/actBack/getActivityBeans.do?pz=10"
											class="${pageSize == 10 ? 'fontpink' : ''}">10</a> | <a
											href="<%=request.getContextPath()%>/back/actBack/getActivityBeans.do?pz=20"
											class="${pageSize == 20 ? 'fontpink' : ''}">20</a>
									</div>
									<div class="fr fontblack mt5 mb20 mr20">
										<jsp:include page="../template/commonPagination.jsp">
											<jsp:param name="url" value="getActivityBeans.do?"></jsp:param>
										</jsp:include>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>

			<div class="clear"></div>
		</div>

	</div>
	
 <script type="text/javascript">
	     $("#table tr").on("click", "td:eq(8) input[name='update']:eq(0)", function(e) {
	        closeOtherJDialog();
	        e.stopPropagation();
	        var dialog =  $("#update_manager_dialog");
	         dialog.dialog("open");
              var tr = $(this).parent().parent();
		      tr.data("tdArr", ["td:eq(9)","td:eq(1)","td:eq(11)","td:eq(6)","td:eq(7)","td:eq(12)","td:eq(13)","td:eq(10)"]);
		      tr.data("inputArr", ["input:eq(0)","input:eq(1)","textarea:eq(0)","input:eq(2)","input:eq(3)","input:eq(4)","input:eq(5)","select:eq(0)"]);
		      for (var i = 0, length = tr.data("tdArr").length; i < length; i++) {
		       $(tr.data("inputArr")[i], dialog).val($.trim($(tr.data("tdArr")[i], tr).text()));
		 }
   
	     });
	          
  </script> 
		<!-- 添加活动信息 -->
		<div id="add_manager_dialog" title="添加活动信息" style="display:none;">
		<div class="box span10 oh">
			<table class="list_table"  id="tb_version_update" >
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;活动名称:</td>
					<td>
					<input type="text" id="iployname" name="iphone"
										class="input-text_popup_form" style="width:300px" maxlength="50"
										>
										
										</td>
				</tr>
	            <tr class="tr">
					<td align="left">&nbsp;&nbsp;活动描述:</td>
					<td><textarea   id="iployDesc" class="input-text_popup_form pl10 ml10"
						style="height:200px;width:90%;"></textarea></td>
				</tr>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;活动开始时间:</td>
					<td> 
					<input type="text" onclick="WdatePicker();" id="istartTime" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'toDateInput\')}', minDate:'#F{$dp.$D(\'toDateInput\',{M:-2})}'})"
										class="Wdate" style="width:150px;padding-left:3px;"
										name="istartTime" />
					</td>
				</tr>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;活动结束时间:</td>
					<td>
					<input type="text" onclick="WdatePicker();" id="iendTime" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'toDateInput\')}', minDate:'#F{$dp.$D(\'toDateInput\',{M:-2})}'})"
										class="Wdate" style="width:150px;padding-left:3px;"
										name="iendTime" />
                    </td>
				</tr>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;活动图片:</td>
					<td>
					<div>
							<input type="file" name="fileName" class="ml10" style="height:36px;" id="file_upload" /> 
							<input id="uploadButton" type="button"
								onclick="$('#file_upload').uploadify('upload');" value="开始上传"
								class="ext_btn ext_btn_success" style="display:none;">
							<p class="fontpink" id="onlyOneImg" style="display:none;">只能上传一张图片</p>
							<input type="hidden" id="iphoto"   />
							<input type="hidden" id="iifUpPic"   value="0" />
							</div>
                    </td>
				</tr>
				
				 
			</table>
		</div>
		</div>
		<!-- 修改活动信息 -->
		<div id="update_manager_dialog" title="更新活动信息" style="display:none;">
		<div class="box span10 oh">
		<input type="hidden" id="uployid"   />
			<table class="list_table"  id="tb_version_update" >
				<tr class="tr">
				    
					<td align="left">&nbsp;&nbsp;活动名称:</td>
					<td>
					<input type="text" id="uployname" name="uphone"
										class="input-text_popup_form" style="width:300px" maxlength="50"
										>
										
										</td>
				</tr>
	            <tr class="tr">
					<td align="left">&nbsp;&nbsp;活动描述:</td>
					<td><textarea   id="uployDesc" class="input-text_popup_form pl10 ml10"
						style="height:200px;width:90%;"></textarea></td>
				</tr>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;活动开始时间:</td>
					<td> 
					<input type="text" onclick="WdatePicker();" id="ustartTime" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'toDateInput\')}', minDate:'#F{$dp.$D(\'toDateInput\',{M:-2})}'})"
										class="Wdate" style="width:150px;padding-left:3px;"
										name="ustartTime" />
					</td>
				</tr>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;活动结束时间:</td>
					<td>
					<input type="text" onclick="WdatePicker();" id="uendTime" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'toDateInput\')}', minDate:'#F{$dp.$D(\'toDateInput\',{M:-2})}'})"
										class="Wdate" style="width:150px;padding-left:3px;"
										name="uendTime" />
                    </td>
				</tr>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;状态:</td>
					<td><select id="ustatus" name="ustatus" class="select pd10">
					<option value="0">无效</option>
					<option value="1">有效</option>
					</select>
				</td>
				</tr>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;活动图片:</td>
					<td>
					<div>
					<input type="hidden" id="uphoto"   />
					<input type="hidden" id="uploypic"   />
							<input type="file" name="fileName" class="ml10" style="height:36px;" id="ufile_upload" /> 
							<input id="uuploadButton" type="button"
								onclick="$('#ufile_upload').uploadify('upload');" value="开始上传"
								class="ext_btn ext_btn_success" style="display:none;">
							<p class="fontpink" id="uonlyOneImg" style="display:none;">只能上传一张图片</p>
							<input type="hidden" id="uifUpPic"   value="0" />
							</div>
                    </td>
				</tr>
				
				 
			</table>
		</div>
		</div>

<script type="application/javascript">
</script>
</body>

</html>
b